<script lang="ts" setup>
import { editLockService } from '../../../../api/lockService'
import { HttpStatusCode } from "axios"
import { ElMessage } from "element-plus"

const emits = defineEmits(['increase', 'closeShow'])
const prop = defineProps<{
  lockServiceForm: ListLockService
}>()

const submitData = async () => {
  const res = await editLockService(prop.lockServiceForm.id, prop.lockServiceForm)
  if(res.statusCode === HttpStatusCode.Created || res.statusCode === HttpStatusCode.Ok) {
    emits('increase', 1, '')
    emits('closeShow')
    ElMessage({
      message: '修改成功',
      type: 'success',
    })
  } else {
    ElMessage({
      message: '添加失败',
      type: 'error',
    })
  }
}
</script>

<template>
  <el-form
      label-position="top"
      label-width="100px"
      :model="prop.lockServiceForm"
      style="max-width: 460px"
  >
    <el-form-item label="锁定天数">
      <el-input-number v-model="prop.lockServiceForm.lockNum">
      </el-input-number>
    </el-form-item>
    <el-form-item label="所需积分">
      <el-input-number v-model="prop.lockServiceForm.useCoin">
      </el-input-number>
    </el-form-item>
    <el-form-item label="备注">
      <el-input :rows="2" type="textarea" v-model="prop.lockServiceForm.remark" />
    </el-form-item>
  </el-form>
  <el-button type="primary" @click="submitData">提交</el-button>
</template>

<style lang="less" scoped>

</style>